
<template>
  <div class="student">
    <h2>姓名：{{name}}</h2>
    <h2>年龄：{{age}}</h2>
    <button @click="sendName">点我发送数据</button>
  </div>
</template>

<script >
  export default  {
    name: 'Student',
    data() {
      return {
        name:"张三",
        age:18
      }
    },
    methods: {
      sendName(){
        console.log(this.name)
       this.$emit('sendname',this.name)
      }
    }
  }
</script>
<style scoped>
.student{
  background-color: pink;
}
</style>